﻿using OddUserManager.Data.IRepositories;
using OddUserManager.Model;
using OddUserManager.Service.IServices;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace OddUserManager.Service.Services
{
    public class OddService : IOddService
    {
        public IOddRepository _oddrepository;
        public OddService(IOddRepository oddrepository)
        {
            _oddrepository = oddrepository;
        }
        public void DeleteBatchOdd(List<int> ids)
        {
            ids.ForEach(p =>
            {
                _oddrepository.DeleteById(p);
            });

        }


        public List<SelectedMatchOddData> GetSelectedMatchOddDataByMatchIds(List<int> ids) {
            return _oddrepository.GetSelectedMatchOddDataByMatchIds(ids);
        }


        public void DeleteOddById(int id)
        {
            _oddrepository.DeleteById(id);
        }

        public List<Odd> GetAllList()
        {
            return _oddrepository.GetAllList().ToList();
        }

        public List<Odd> GetAllList(int pageIndex, int pageSize, out int dataCount)
        {
            return _oddrepository.GetAllList(pageIndex, pageSize, out dataCount);
        }

        public List<Odd> GetAllPageList(int startPage, int pageSize, out int rowCount, Func<Odd, bool> where, Func<Odd, object> order)
        {
            return _oddrepository.LoadPageList(startPage, pageSize, out rowCount, where, order).ToList();
        }

        public Odd GetOddById(int id)
        {
            return _oddrepository.Get(id);
        }

        public List<Odd> GetAllList(int[] oddMoneyTypes, int oddState, int pageIndex, int pageSize, out int dataCount)
        {
            return _oddrepository.GetAllList(oddMoneyTypes, oddState, pageIndex, pageSize, out dataCount);
        }
        public List<Odd> GetOddsBySiteIds(string siteIds, int[] oddMoneyTypes, int oddState, int pageIndex, int pageSize, out int dataCount)
        {
            return _oddrepository.GetOddsBySiteIds(siteIds, oddMoneyTypes, oddState, pageIndex, pageSize, out dataCount);
        }

        public List<Odd> GetOddsByCreateUserId(int id)
        {
            return _oddrepository.GetOddsByCreateUserId(id);
        }

        public List<Odd> GetOddsBySiteIds(string siteIds, int pageIndex, int pageSize, out int dataCount)
        {
            return _oddrepository.GetOddsBySiteIds(siteIds, pageIndex, pageSize, out dataCount);
        }

        public List<Odd> GetUnfinishedOdds()
        {
            return _oddrepository.GetUnfinishedOdds();
        }

        public bool InsertOrUpdateOdd(Odd dto)
        {
            return _oddrepository.InsertOrUpdate(dto);
        }

        public bool UpdateOddDetailsContents(int id, List<BetDetailOdd> list)
        {
            return _oddrepository.UpdateOddDetailsContents(id, list);
        }

        public void UpdateCertification(int oddId, bool certification, int confirmAppUserId)
        {
            _oddrepository.UpdateCertification(oddId, certification, confirmAppUserId);
        }

        public List<Odd> GetOddBySiteIdsAndTime(DateTime startTime, DateTime endTime, string siteIds)
        {
            return _oddrepository.GetOddBySiteIdsAndTime(startTime, endTime, siteIds);
        }

        public List<Odd> GetOddBySelectedMatchIds(List<int> ids) {
            return _oddrepository.GetOddBySelectedMatchIds(ids);
        }
    }
}
